import java.io.IOException;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class UDPClient {
    public static void main(String[] args){
        try {
            DatagramSocket socket = new DatagramSocket();
            Scanner scanner = new Scanner(System.in);
            while(scanner.hasNextLine()){
                byte[] buff = scanner.nextLine().getBytes(StandardCharsets.UTF_8);
                DatagramPacket out = new DatagramPacket(new byte[0], 0, InetAddress.getByName("127.0.0.1"), 4396);
                out.setData(buff);
                socket.send(out);
            }
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
